package cn.wenzy.aurora.framework.exception;

import cn.hutool.extra.spring.SpringUtil;
import cn.wenzy.aurora.framework.support.i18n.I18nSupport;
import lombok.Getter;
import org.slf4j.event.Level;

import java.io.Serial;

public class CommonException extends RuntimeException {
    @Getter
    private Level level;

    @Serial
    private static final long serialVersionUID = 1L;

    public CommonException(Throwable cause) {
        super(cause);
        level = Level.ERROR;
    }

    public CommonException(String message, Object... args) {
        super(SpringUtil.getBean(I18nSupport.class).getMessage(message, args));
        level = Level.WARN;
    }

    public CommonException(String message, Throwable cause) {
        super(SpringUtil.getBean(I18nSupport.class).getMessage(message), cause);
        level = Level.ERROR;
    }

    public CommonException(String message, Throwable cause, String... args) {
        super(SpringUtil.getBean(I18nSupport.class).getMessage(message, args), cause);
        level = Level.ERROR;
    }

    public CommonException(Throwable cause, String message, String... args) {
        super(SpringUtil.getBean(I18nSupport.class).getMessage(message, args), cause);
        level = Level.ERROR;
    }

}
